Q: How does a submission obtain secure randomness?
 
A: The function randombytes() will be available to the submitters. This is a function that will be available in the test environment and should be used to generate seed values for an algorithm. If the algorithm needs additional randomness beyond the seed value a NIST-approved DRBG should be used. If a non-approved DRBG is used “the submitter shall provide an explanation for why a NIST-approved primitive would not be suitable.” The length of the random value obtained from randombytes() should be selected to match one of the security categories in the call for algorithms. That is, if the call to generate a key pair is from category 1 the randomness value should be 128 bits (16 bytes), if the call is from category 2 or 3 it should be 192 bits (24 bytes) and if it is from category 4 or 5 it should be 256 bits (32 bytes). The DRBG will be used to expand that if necessary.

For functional and timing tests a deterministic generator is used inside randombytes() to produce the seed values. If security testing is being done simply substitute calls to a true hardware RBG inside randombytes().
 
Function prototype for randombytes() is:
 
// The xlen parameter is in bytes
void randombytes(unsigned char *x,unsigned long long xlen)
 
The following demonstrate the use of the KAT and non-KAT versions of the functions to generate a key pair for encryption:
 
int crypto_encrypt_keypair_KAT(
              unsigned char *pk,
              unsigned char *sk,
              const unsigned char *randomness
         )
 
int crypto_encrypt_keypair(unsigned char *pk, unsigned char *sk)
{
      unsigned char pk[CRYPTO_PUBLICKEYBYTES];
      unsigned char sk[CRYPTO_SECRETKEYBYTES];
      unsigned char seed[CRYPTO_RANDOMBYTES];
 
      randombytes(seed, CRYPTO_RANDOMBYTES);
      crypto_encrypt_keypair_KAT(pk, sk, seed);
}